package com.usian.exception;

import com.sun.xml.internal.ws.handler.HandlerException;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Configuration
public class GlobalException implements HandlerExceptionResolver {


    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {

        //方法体处理统一异常的结果
        ModelAndView modelAndView =new ModelAndView();
        modelAndView.setViewName("error2");
        System.out.println(e);
        return modelAndView;
    }
}
